// 重载运算符 输出类
#include <iostream>

using namespace std;

// 时间类
class Time
{
    // 设置友元
    friend ostream &operator<<(ostream &out, Time &ob);
    friend istream &operator>>(istream &in, Time &t);
    friend bool operator==(Time &t1, Time &t2);
    //friend Time operator+(Time &t1, Time &t2);
public:
    Time operator+(Time &t)
    {
        Time tmp;
        tmp.mHour = t.mHour + mHour;
        tmp.mMin = t.mMin + mMin;
        tmp.mSec = t.mSec + mSec;

        return tmp;
    }
#if 0
    bool operator==(Time &t)
    {
        if (this->mHour == t.mHour && \
            this->mMin == t.mMin && \
            this->mSec == t.mSec)
        {
            return true;
        }
        else 
        {
            return false;
        }
    }
#endif
public:
    Time();
    Time(int h, int m, int s);
    Time(const Time & ob);
    ~Time();    
private:
    int mHour;
    int mMin;
    int mSec;
};

// 重载插入运算符
ostream &operator<<(ostream &out, Time &ob)
{
    out << ob.mHour << " " << ob.mMin << " " << ob.mSec;
    return out;
}

istream &operator>>(istream &in, Time &t)
{
    in >> t.mHour >> t.mMin >> t.mSec;
    return in;
}

#if 0
Time operator+(Time &t1, Time &t2)
{   
    Time tmp;
    tmp.mHour = t1.mHour + t2.mHour;
    tmp.mMin = t1.mMin + t2.mMin;
    tmp.mSec = t1.mSec + t2.mSec;

    return tmp;
}   
#endif

bool operator==(Time &t1, Time &t2)
{
    if (t1.mHour == t2.mHour && \
        t1.mMin == t2.mMin && \
        t1.mSec == t2.mSec)
    {
        return true;
    }
    else 
    {
        return false;
    }
}

int main(int argc, char **argv)
{
    Time t1(1, 2, 3);
    Time t2(4, 5, 6);

    Time t3;
    t3 = t1 + t2;

    cout << t3 << endl;
    if (t1 == t2)
    {
        cout << "相同" << endl;
    }
    else 
    {
        cout << "不相同" << endl;
    }

    return 0;
}



Time::Time()
{
    // 无参构造
    this->mHour = 0;
    this->mMin = 0;
    this->mSec = 0;
}

Time::Time(int h, int m, int s)
{
    // 有参构造
    this->mHour = h;
    this->mMin = m;
    this->mSec = s;
}

Time::Time(const Time & ob)
{
    // 拷贝构造
    this->mHour = ob.mHour;
    this->mMin = ob.mMin;
    this->mSec = ob.mSec;
}

Time::~Time()
{
    // 析构函数
}  
